﻿using System;
using System.Web;
using System.Web.Mvc;
using CourseSystem.Common.Helpers;
using CourseSystem.Core.Enum;

namespace CourseSystem.Stat.ActionFilter
{
    public class StatFilter : FilterAttribute, IActionFilter
    {
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpContext context = HttpContext.Current;
            var url = context.Request.RawUrl;
            //在线统计
            UserOnlineStat.Stat();
            //保鲜地址不做Ip统计/点击统计
            if (url.IndexOf("stat/flash", StringComparison.CurrentCultureIgnoreCase) > 0)
                return;
            //点击统计
            IpStat.HitsStat();
            //IP统计
            IpStat.IpStatDo();
         }

        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            return;
        }
    }
}
